<?php


namespace app\api\controller\v1;

use app\api\validate\IDMustBeInt;
use app\api\model\Banner as BannerModel;
use app\lib\exception\BannerMissException;
use think\Exception;

class Banner
{
    /**
     * 获取指定id的banner信息
     * @url /banner/:id
     * @http GET
     * @param $id banner的Id号
     */
    public function getBanner($id) {

        (new IDMustBeInt()) -> goCheck();

        $banner = BannerModel::getBannerById($id);
        if (!$banner) {
            throw new BannerMissException();
        }
        return json($banner);
        //独立验证
        //验证器
//        $data = [
//            'name' =>'vendo123124112314121r',
//            'eamil' => 'verndorq@qq.com'
//        ];
//        $validate = new Validate([
//            'name'=> 'require|max:10',
//            'email' => 'email'
//        ]);
//        $result = $validate-> batch() -> check($data);
//        var_dump($validate -> getError());

//        $data = [
//            'name' =>'vendo123124124214121r',
//            'eamil' => 'verndorq@qq.com'
//        ];
//        $validate = new TestValidate();
    }
}